package com.nuc.zyt.Controller;

import com.nuc.zyt.Pojo.Student;
import com.nuc.zyt.Service.UserService;
import com.nuc.zyt.aspect.UserProxy;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.Resource;

/**
 * @ClassName App
 * @Description TODO
 * @Author 耀酱
 * @Date 2023/6/5 15:54
 * @Version 1.0
 */
public class App {
    public static void main(String[] args) {

        System.out.println("基于xml");
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
//        System.out.println("getApplicationName: "+applicationContext.getApplicationName());
//        System.out.println("getAutowireCapableBeanFactory(): "+applicationContext.getAutowireCapableBeanFactory());
//        System.out.println("类加载器："+applicationContext.getClassLoader());

        UserService userService = applicationContext.getBean("userService", UserService.class);
//        userService.getMessage();
//        Student student1 = userService.getId(1);
//        System.out.println(student1);

        userService.update();

//        Student student = applicationContext.getBean("student", Student.class);
//        System.out.println(student);
//
//        System.out.println("getEnvironment():"+applicationContext.getEnvironment());
//
//        Resource resource = applicationContext.getResource("applicationContext.xml");

//        System.out.println("基于注解");
//        // 基于注解 将xml里的内容逐个替换为注解实现
//        AnnotationConfigApplicationContext applicationContext1 = new AnnotationConfigApplicationContext("applicationContext.xml");
//        Student student = applicationContext1.getBean("student", Student.class);
//        System.out.println(student);


    }
}
